using System;

class FallDownBits
{
	static void Main(string[] args)
	{
		const byte arraySize = 8;
		byte[] numbers = new byte[arraySize];
		for (int currentNumber = 0; currentNumber < arraySize; currentNumber++)
		{
			numbers[currentNumber] = Convert.ToByte(Console.ReadLine());
		}

		for (int currentBit = 0; currentBit < 8; currentBit++)
		{
			for (int currentStartingNumber = arraySize - 1; currentStartingNumber > 0; currentStartingNumber--)
			{
				if (GetBitAtPosition(numbers[currentStartingNumber], currentBit) == 0)
				{
					int lastIndexOfOne = currentStartingNumber - 1;
					while (lastIndexOfOne >= 0 && (GetBitAtPosition(numbers[lastIndexOfOne], currentBit) == 0))
					{
						lastIndexOfOne--;
					}
					if (lastIndexOfOne < 0)
					{
						break;
					}
					else
					{
						numbers[currentStartingNumber] = SetBitAtPosition(numbers[currentStartingNumber], currentBit, 1);
						numbers[lastIndexOfOne] = SetBitAtPosition(numbers[lastIndexOfOne], currentBit, 0);
					}
				}
			}
		}

		for (int currentNumber = 0; currentNumber < arraySize; currentNumber++)
		{
			Console.WriteLine(numbers[currentNumber]);
		}
	}

	private static byte GetBitAtPosition(byte number, int position)
	{
		if ((number >> position) % 2 == 0)
		{
			return 0;
		}
		else return 1;
	}

	private static byte SetBitAtPosition(byte number, int position,
		byte valueOfBit)
	{
		byte mask;
		if (valueOfBit == 1)
		{
			mask = (byte)(valueOfBit << position);
			number = (byte)(number | mask);
		}
		else
		{
			mask = (byte)(~(1 << position));
			number = (byte)(number & mask);
		}
		return number;
	}
}


